#include<stdio.h>
int main()
#pragma warning(disable:4996)
{
	int p(int x, int y);
	int n;
	scanf("%d", &n);
	int min = p(10, n - 1);
	int max = p(10, n);
	int sum = 0;
	int m = 0;
	for (int i = 0; i < max; i++)
	{
		while (i > 0)
		{
			m = i % 10;
			i /= 10;
			sum += p(m, n);
		}
		if (sum = i)
		{
			printf("%d", i);
		}
	}
	return 0;
}
int p(int x, int y)
{
	for (int i = 1; i < y; i++)
	{
		int k = x;
		x = x*k;
	}
	return x;
}
